#include <iostream>
#include <string>
#include <memory>
#include "udpserver.hpp"

std::string defaulthandler(const std::string& buf)
{
    std::string ret = "I am server, I say: ";
    ret += buf;

    return ret;
}

// 启动格式：./udpserver port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Please Entry Like: ./udpserver ip port!" << std::endl;
        exit(3);
    }

    //std::string ip = (const char *)argv[1];
    uint16_t port = std::stoi(argv[1]);

    Enable_Console_Log_Strategy();

    std::unique_ptr<UdpServer> udps = std::make_unique<UdpServer>(port,defaulthandler);
    udps->Init();
    udps->Start();
    return 0;
}